package com.tjbank.cssys.web.service.impl;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tjbank.cssys.domain.CkCreditRecoverMoney;
import com.tjbank.cssys.repository.CkCreditRecoverMoneyMapper;
import com.tjbank.cssys.web.service.CkCreditRecoverMoneyService;
import com.tjbank.cssys.web.util.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
@Service
public class CkCreditRecoverMoneyServiceImpl implements CkCreditRecoverMoneyService {

    private static Logger logger = LoggerFactory.getLogger(CkCreditRecoverMoneyServiceImpl.class);

    @Autowired
    private CkCreditRecoverMoneyMapper ckCreditRecoverMoneyMapper;


    @Override
    public PageInfo selectRePeoples(Map<String, String> params) {
        logger.info("信贷还款人列表数据查询---start,params=" + JSON.toJSONString(params));
        int page = Integer.parseInt(params.getOrDefault("page", "1").toString());
        int pageSize = Integer.parseInt(params.getOrDefault("pageSize", "10").toString());
        params.put("state","2");// 2为回款
        PageHelper.startPage(page, pageSize);
        List<Map<String,Object>> ckCreditRecoverMonies = ckCreditRecoverMoneyMapper.selectRePeoples(params);

        PageInfo result = new PageInfo(ckCreditRecoverMonies);
        result.setList(MapUtils.formatHumpNameForList(result.getList()));
        logger.info("信贷还款人列表数据查询---end,PageInfo=" + JSON.toJSONString(result));
        return result;
    }


    @Override
    public PageInfo selectReList(Map<String, String> params){
        logger.info("信贷还款列表数据查询---start,params=" + JSON.toJSONString(params));
        int page = Integer.parseInt(params.getOrDefault("page", "1").toString());
        int pageSize = Integer.parseInt(params.getOrDefault("pageSize", "10").toString());
        params.put("state","2");// 2为回款
        PageHelper.startPage(page, pageSize);
        List<Map<String,Object>> ckCreditRecoverMonies = ckCreditRecoverMoneyMapper.selectReList(params);

        PageInfo result = new PageInfo(ckCreditRecoverMonies);
        result.setList(MapUtils.formatHumpNameForList(result.getList()));
        logger.info("信贷还款列表数据查询---end,PageInfo=" + JSON.toJSONString(result));
        return result;
    }
}
